package xyz.xpman.prisonerfitness.activity;

import android.app.Activity;
import android.graphics.Point;
import android.os.Build;
import android.os.Bundle;
import android.widget.LinearLayout;

import androidx.annotation.RequiresApi;

import xyz.xpman.prisonerfitness.R;
import xyz.xpman.prisonerfitness.util.ActivityUtil;
import xyz.xpman.prisonerfitness.util.ScreenUtil;

public class TrainingGiveUpActivity extends Activity {

    @RequiresApi(api = Build.VERSION_CODES.O)
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        ActivityUtil.hideBottomUIMenu(this);

        setContentView(R.layout.activity_training_give_up);


        initPopWindow();
        initEvent();
    }

    private void initPopWindow() {
        // 设置窗口宽度，高度则自适应
        Point windowsSize = ScreenUtil.getWindowsSize(this);
        int width = (int)((float) windowsSize.x * 0.60);
        getWindow().setLayout(width, LinearLayout.LayoutParams.WRAP_CONTENT);
    }


    private void initEvent() {
        // 取消：关闭弹窗
        findViewById(R.id.cancel).setOnClickListener(view -> {
            setResult(0);
            finish();
        });


        // 确定：退出训练
        findViewById(R.id.confirm).setOnClickListener(view -> {
            setResult(1);
            finish();
        });
    }

}